package net.openl10n.mdf;

import java.util.LinkedHashSet;
import java.util.Set;

import net.openl10n.mdf.immutable.ImmutableBuilder;
import net.openl10n.mdf.immutable.ImmutableStateException;

public class DataHookBuilder extends AbstractDocumentPartBuilder implements ImmutableBuilder<DataHook>{

	public DataHookBuilder() {
	}
	
	public DataHookBuilder(DataHook dataHook) {
		super(dataHook);
	}
	
	public boolean isValid() {
		return super.isValid();
	}
	
	public void validate() throws ImmutableStateException {
		if(! isValid()) {
			Set<String> invalidFields = new LinkedHashSet<String>();
			super.populateInvalidFields(invalidFields);
			throw new ImmutableStateException(invalidFields);
		}
	}
	
	@Override
	public DataHook build() throws ImmutableStateException{
		validate();
		return new DataHook(id, version);
	}
	
	

}
